<?php
class Message_model extends CI_model {
	public function __construct(){
		$this->load->database();
	}
	
	public function get_message(){
		$d = $this->db->get('messages');
		return $d;
	}
	public function getby_msg($id){
		$d = $this->db->get_where('messages', array('id'=>$id));
		return $d->row_array();
	}

	public function page_message($page=0, $perpage=20){
		$result = $this->db->query("SELECT * FROM `messages` LIMIT {$page}, {$perpage}");
		return $result->result_array();
	}

	public function set_msg(){
		$fields = array('title','content', 'author','company','tel','email');
		foreach($fields as $f){
			$data[$f] = $this->input->post($f);
		}
		$data['createtime'] = date("Y-m-d H:i:s");
		
		return $this->db->insert('messages', $data);
		 
	}
}

/* End of file message_model.php */
/* Location: ./application/model/message_model.php */